const express = require('express')
const app = express()
const path = require('path')
const url = require('node:url');
const bodyParser = require('body-parser')

// app.use(express.static(path.resolve(__dirname,'./public')))
app.use((req,res,next)=>{
    // let s = req.get('referer')
    // console.log(s,'--')
    
    next()
})
app.get('/submit',(req,res)=>{
    
    res.sendFile(__dirname+'/public/index.html')
})

// 解析 application/json 格式
const jsonParser = bodyParser.json()

// 解析 application/x-www-form-urlencoded 格式
// const urlencodedParser = bodyParser.urlencoded()
app.use(express.urlencoded())
app.post('/submit',(req,res)=>{
    console.log(req.body)
    res.send('submit success')
})

app.listen('3000',()=>{
    console.log('server start success....')
})